import Vue from "vue";
import Vuex from "vuex";
import user from "./modules/user";
// 持久化存储store 防止页面强制刷新之后store会失效
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules: {
    user, //用户信息
  },
  plugins: [
    createPersistedState({
      storage: window.localStorage, // 使用 localStorage
      //默认全部进行持久化存储 如果只想持久化部分数据 可以使用reducer
      // reducer(val) {
      //   return {
      //     aboutLogin: {
      //       userInfo: val.aboutLogin.userInfo
      //     },
      //     aboutSchool: {
      //       schoolInfo: val.aboutSchool.schoolInfo
      //     }
      // };
      // }
    }),
  ],
});
